{include file="common/head"/}

  <script src="//unpkg.com/jquery@3.3.1/dist/jquery.min.js"></script>
  <script type="text/javascript" src="/static/ueditor/ueditor.config.js"></script>
  <script type="text/javascript" src="/static/ueditor/ueditor.all.js"></script> 
<style>
    .layui-text em, .layui-word-aux{
        color: red !important;
    }
</style>
<div class="admin-main layui-anim layui-anim-upbit" ng-app="hd" ng-controller="ctrl">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>修改</legend>
    </fieldset>
    <form class="layui-form layui-form-pane">
        
        <!-- 任务名称 S -->
        <div class="layui-form-item">
            <label class="layui-form-label"> 任务名称 </label>
            <div class="layui-input-4">
                <input type="number" name="title" lay-verify="required" value="{$infoArr['title']}" class="layui-input" autocomplete="off">
            </div>
            <div class="layui-form-mid layui-word-aux required">*</div>
        </div>
        <!-- 任务名称 E -->

        <!-- 任务目标 S -->
<!--        <div class="layui-form-item">-->
<!--            <label class="layui-form-label"> 任务目标 </label>-->
<!--            <div class="layui-input-4">-->
<!--                <input type="text" name="task_target" ng-model="field.task_target" lay-verify="required"  class="layui-input" autocomplete="off">-->
<!--            </div>-->
<!--            <div class="layui-form-mid layui-word-aux required">*</div>-->
<!--        </div>-->
        <!-- 任务目标 E -->

        <!-- 内容 S -->
        <div class="layui-form-item">
            <label class="layui-form-label">内容</label>
            <div class="layui-input-4">
                <textarea name="describe" placeholder="请输入内容" class="layui-textarea">{$infoArr['describe']}</textarea>
            </div>
        </div>
        <!-- 内容 E -->

        <!-- 类型 S -->
        <div class="layui-form-item">
            <label class="layui-form-label">类型</label>
            <div class="layui-input-4">
                <input type="radio" name="type" value="1" title="本周" {eq name="$infoArr['type']" value="1" } checked="" {/eq}>
                <input type="radio" name="type" value="2" title="下周" {eq name="$infoArr['type']" value="2" } checked="" {/eq}>
            </div>
        </div>
        <!-- 类型 E -->

        <!-- 开始时间 S -->
        <div class="layui-form-item">
            <label class="layui-form-label"> 开始时间 </label>
            <div class="layui-input-4">
                <input type="text" name="begin_time" ng-model="field.begin_time" id="begin_time" disabled class="layui-input" autocomplete="off">
            </div>
        </div>
        <!-- 开始时间 E -->

        <!-- 结束时间 S -->
        <div class="layui-form-item">
            <label class="layui-form-label"> 结束时间 </label>
            <div class="layui-input-4">
                <input type="text" name="end_time" ng-model="field.end_time" id="end_time" disabled class="layui-input" autocomplete="off">
            </div>
        </div>
        <!-- 结束时间 E -->

        <!-- 发布时间 S -->
        <div class="layui-form-item">
            <label class="layui-form-label"> 发布时间 </label>
            <div class="layui-input-4">
                <input type="text" name="create_time" ng-model="field.create_time" id="create_time" class="layui-input" autocomplete="off">
            </div>
        </div>
        <!-- 发布时间 E -->

        <!-- 排序 S -->
        <div class="layui-form-item">
            <label class="layui-form-label"> 排序 </label>
            <div class="layui-input-4">
                <input type="text" name="sort" ng-model="field.sort" class="layui-input" autocomplete="off">
            </div>
        </div>
        <!-- 排序 E -->

        <!-- 是否禁用 S -->
        <div class="layui-form-item">
            <label class="layui-form-label">是否禁用</label>
            <div class="layui-input-4">
                <input type="radio" name="status" value="1" {eq name="$infoArr['status']" value="1" } checked="" {/eq} title="否">
                <input type="radio" name="status" value="2" {eq name="$infoArr['status']" value="2" } checked="" {/eq} title="是">
            </div>
        </div>
        <!-- 是否禁用 E -->

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="button" class="layui-btn" lay-submit="" lay-filter="submit">{:lang('submit')}</button>
<!--                <a href="{:url('index')}" class="layui-btn layui-btn-primary">{:lang('back')}</a>-->
            </div>
        </div>
    </form>
</div>
{include file="common/foot"/}

  <link href="/static/common/css/formSelects-v4.css" rel="stylesheet" />

 
<script src="/static/common/js/angular.min.js"></script>
<script>
    
  
  UE.getEditor('content',{
        initialFrameWidth : 600,
        initialFrameHeight: 600,
     });

      
   layui.config({
        base: '/static/common/js/' //此处路径请自行处理, 可以使用绝对路径
    }).extend({
        formSelects: 'formSelects-v4'
    });

       
    var m = angular.module('hd',[]);
    m.controller('ctrl',function($scope) {
        $scope.field = {$info|raw};
        layui.use(['form','upload', 'layer','layedit','formSelects'], function () {
            var form = layui.form, layer = layui.layer,$= layui.jquery,upload = layui.upload,layedit = layui.layedit;
             
               
             var info = {$info|raw}; form.val("form", info);  if(info){ $("#pic").attr("src",info.pic); }
var info = {$info|raw}; form.val("form", info);  if(info){ $(".pic").attr("value",info.pic); }

              var formSelects = layui.formSelects;
             

            form.on('submit(submit)', function (data) {

                // 提交到方法 默认为本身
                var loading = layer.load(1, {shade: [0.1, '#fff']});
                data.field.id = $scope.field.id;
                 //获取编辑器的内容
                $.post("", data.field, function (res) {
                    layer.close(loading);
                    if (res.code > 0) {
                        // sessionStorage.setItem("changeData", JSON.stringify(data.field));
                        layer.msg(res.msg, {time: 1800, icon: 1}, function () {
                            location.href = res.url;
                        });
                    } else {
                        layer.msg(res.msg, {time: 1800, icon: 2});
                    }
                });
            })


               
    var uploadInst = upload.render({ 
            elem: ".uploadImg" ,
            url: "{:url("UpFiles/upload")}" ,
            before: function(obj){
              var _this = this;
              obj.preview(function(index, file, result){
                   _this.item.parents(".fieldName").find("img").attr("src",result)
              });  
            },
            done: function(res){ 
                if(res.code>0){ 
                  this.item.parents(".fieldName").find("input[type=hidden]").val(res.url)
                }else{ 
                  return layer.msg("上传失败");
                } 
            } ,
              error: function(res){ 
                var demoText = this.item.parents(".fieldName").find(".demoText");
                 demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');  
                 demoText.find(".demo-reload").on("click", function(){  
                  uploadInst.upload(); 
                });
              }
        });


                
        });
    });


    // 时间插件shi-jian-cha-jian
    
useLayDateMultiple('begin_time');

useLayDateMultiple('end_time');

useLayDateMultipleTime('create_time');


    function useLayDateMultiple(cls) {
        layui.use('laydate', function() {
            var laydate = layui.laydate;
            lay('#' + cls).each(function() {
                laydate.render({
                    elem : this,
                    trigger : 'click',
                    type : 'date'
                });
            });
        });
    }

  function useLayDateMultipleTime(cls) {
      layui.use('laydate', function() {
          var laydate = layui.laydate;
          lay('#' + cls).each(function() {
              laydate.render({
                  elem : this,
                  trigger : 'click',
                  type : 'datetime'
              });
          });
      });
  }
</script>
</body>
</html>